package com.oa.gongwen.biz;

import java.util.List;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import com.oa.gongwen.dao.AuditPersonMapper;
import com.oa.gongwen.dao.GongwenMapper;
import com.oa.gongwen.entity.AuditPerson;
import com.oa.gongwen.entity.Gongwen;

@Service
public class OfficialDocumentBiz {

	@Resource
	private GongwenMapper gMapper;
	
	@Resource
	private AuditPersonMapper aMapper;
	
	public void save(Gongwen gongwen){
		gMapper.insert(gongwen);
	}
	//查数据量
	public int count(){
		return gMapper.count();
	}
	//查数据量2
		public int count2(){
			return gMapper.count2();
		}
	//根据公文id查询审批
    public List<AuditPerson> selectAuditPerson(int Id){
    	
    	return aMapper.selectByGongwenid(Id);
    }
    
    //根据id查公文
    public Gongwen selectOne(Integer id){
    	return gMapper.selectById(id);
    }
    
    //存储批示人信息
    public void insert(AuditPerson auditPerson){
    	  aMapper.insert(auditPerson);
    }
    
    //根据状态查询公文
	public List<Gongwen> selectGW(Integer state,Integer pageno){
    	return (List<Gongwen>) gMapper.selectByPrimaryKey(state,pageno);
    }
	
	public List<Gongwen> selectGWs(Integer state,String use,Integer pageno){
    	return (List<Gongwen>) gMapper.selectByPrimaryKeys(state,use,pageno);
    }
	//根据id查单个公文
	public Gongwen justlook(Integer id){
		return gMapper.selectById(id);
	}
	
	//查看公文并可以审批
	public List<Gongwen> selectBydo(Integer state,int agree){
    	return (List<Gongwen>) gMapper.selectBydo(state,agree);
    }
	
	//根据id修改公文内容
	public void updategongwen(Gongwen gongwen){
		gMapper.updateByPrimaryKeySelective(gongwen);
	}
	//删除
	public void delete(Integer id){
		gMapper.deleteByPrimaryKey(id);
	}
	
}
